package ui;
//-*- mode:java; Encoding:utf8n -*-
//http://terai.xrea.jp/Swing/SortableTable.html

public class ResultTestModel extends SortableTableModel {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public ResultTestModel(String[] str, int row) {
		super(str, row);
		// TODO 自動生成されたコンストラクター・スタブ
	}

	ResultTestModel() {
		super();
		// TODO 自動生成されたコンストラクター・スタブ
	}
	private static final ColumnContext[] columnArray = {
        new ColumnContext("id",     Integer.class, false),
        new ColumnContext("Title",    String.class,  false),
        new ColumnContext("Year", Integer.class,  false),
    };
    private int number = 0;
    public void addTest(ResultTest t) {
        Object[] obj = {new Integer(number), t.getName(), t.getComment()};
        super.addRow(obj);
        number++;
    }
    public boolean isCellEditable(int row, int col) {
        return columnArray[col].isEditable;
    }
    @SuppressWarnings("unchecked")
	public Class getColumnClass(int modelIndex) {
        return columnArray[modelIndex].columnClass;
    }
    public int getColumnCount() {
        return columnArray.length;
    }
    public String getColumnName(int modelIndex) {
        return columnArray[modelIndex].columnName;
    }
    private static class ColumnContext {
        public final String  columnName;
        public final Class   columnClass;
        public final boolean isEditable;
        public ColumnContext(String columnName, Class columnClass, boolean isEditable) {
            this.columnName = columnName;
            this.columnClass = columnClass;
            this.isEditable = isEditable;
        }
    }
}
class ResultTest{
    private String name, comment;
    public ResultTest(String name, String comment) {
        this.name = name;
        this.comment = comment;
    }
    public void setName(String str) {
        name = str;
    }
    public void setComment(String str) {
        comment = str;
    }
    public String getName() {
        return name;
    }
    public String getComment() {
        return comment;
    }
}
